<?php
    include_once("Configs/database.php");
    include_once("CanBo.php");
    class CanBoGiangDay extends CanBo{
        private $mabm;
        //private $hocvi;
        private $chucdanh;
        
        /*public function setHocVi($hocvi){
            $this->hocvi = $hocvi;
        }*/
        public function setChucDanh($chucdanh){
            $this->chucdanh = $chucdanh;
        }
        public function setMaBM($mabm){
            $this->mabm= $mabm;
        }
        
        /*public function getHocVi(){
            return $this->hocvi;
        }*/
        public function getChucDanh(){
            return $this->chucdanh;
        }
        public function getMaBM(){
            return $this->mabm;
        }
        
		
		
		//********** Nguyễn Ngọc Chánh thêm hàm kiểm tra cán bộ có phải là cán bộ giảng viên không? ***************
		
		 public function check($maso){
           $query = "select * from CanBoGiangDay where maso='$maso'";
           $this->setQuery($query);
           return $this->fetchAll();
        }
		
		//********************************************************************************************************
		
		
        
        public function themCanBoGiangDay(){
            $this->setQuery("insert into CanBoGiangDay(maso,mabm,chucdanh) values('".$this->getMaSo()."','".$this->getMaBM()."','".$this->getChucDanh()."')");
            //echo $this->getQuery();
            return $this->executeQuery();
        }
        public function thongTinCanBoGiangDay(){
            $query = "select a.maso,  concat(holot, ' ', ten) as hoten, date_format(ngaysinh,'%d-%m-%Y') as ngaysinh,
						(case phai when 0 then N'Nữ' when 1 then 'Nam' end) as phai, diachi, email, sodt,
						(case hocvi when 'CN' then N'Cử nhân'
									when 'KS' then N'Kĩ sư' 
									when 'ThS' then N'Thạc sĩ' 
									when 'TS' then N'Tiến sĩ' 
									when 'PGS' then N'Phó giáo sư'
									 when 'GS' then N'Giáo sư' end) as hocvi,
						(case chucdanh when 'GV' then N'Giảng viên' 
									   when 'GVC' then N'Giảng viên chính'
									   when 'TG' then N'Trợ giảng' end) as chucdanh,
						maquyen,tenbm from CanBoGiangDay a, CanBo b,NguoiDung c, Bomon d";
            $query .= " where  a.maso='".$this->getMaSo()."' and a.maso = b.maso and b.maso=c.maso and a.mabm = d.mabm";
            $this->setQuery($query);
            return $this->fetchAll();
        }
        public function suaCanBoGiangDay(){
            $this->setQuery("update CanBoGiangDay set chucdanh='".$this->getChucDanh()."',mabm='".$this->getMaBM()."' where maso='".$this->getMaSo()."'");
			 //echo $this->getQuery();
            return $this->executeQuery();
        }
        public function xoaCanBoGiangDay(){
            $this->setQuery("delete CanBoGiangDay where maso='".$this->getMaSo()."'");
            return $this->executeQuery();
        }
        
         /*public function hienThiKhoaTheoMaQuyen(){
            
            
                $query = "select * from Khoa";
            
            
            $this->setQuery($query);
            return $this->fetchAll();
        }*/
       
        public function dsLopHPDayTrongHKNH($hocki,$namhoc){
            $lophp = new LopHocPhan();
            $lophp->setMaSo($this->getMaSo());
            $lophp->setHocKi($hocki);
            $lophp->setNamHoc($namhoc);
            return $lophp->dsLopHPMoTrongHKNHCuaCBGD();
        }
        
        public function ghiTongKetNhatKiLopHP($malophp,$noidung){
            $this->setQuery("update NhatKi set noidung='".$noidung."' where malophp='".$malophp."'");
            return $this->executeQuery();
        }
        
    }
?>